/*
    This file is part of Slydini.

    Slydini is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Slydini is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Slydini.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PROCESSOR_H
#define _PROCESSOR_H

#include <QtGui>

#include <sys/types.h>
#include <sys/stat.h>

#include <highgui.h>

#include <queue>
#include "utils/iplimage_convert.h"
#include "frame_evaluation/frameevaluation.h"
#include "configuration/configuration.h"
#include "gestures/gesture_detector.h"
#include "painting/SWidget.h"
#include "hand_tracker/hand_tracker.h"
#include "mouse/mouse.h"


using namespace std;

/**
 * \brief Główna klasa odpowiadająca za przetwarzanie kolejnych klatek obrazu.
 *
 * Processor dziedziczy z klasy QWidget. Jego funkcja processFrame odpowiada za przetworzenie jednej klatki pobranej z kamery.
 */
class Processor : public QWidget {
	Q_OBJECT
	public:

		Processor(QWidget *parent);
		int initialize(int argc, char **argv);
		public slots:
		void processFrame();
	signals:
		void quit();
	protected:
		void paintEvent(QPaintEvent *paintEvent);
		void keyReleaseEvent(QKeyEvent* event);
	private:
		void captureFrame();
		void releaseFrame();
		double t;
		int frame_count;
        SWidget *swidget;
		CvCapture *capture;
		IplImage *image, *imageBW, *smallImage, *image_prev;
		QImage *background_image;
		QImage *painterImage;
		Configuration *configuration;
		GestureDetector *gestureDetector;
		HandTracker *handTracker;
		Mouse *mouse;
		IplImage* resized_image;
		bool currentlyClicked;
		//FingersHistory *fingers_history;

};


#endif
